package com.forclass;

public class LayzzySingleton2 {
    private static volatile LayzzySingleton2 instance;
    private LayzzySingleton2() {
        System.out.println("私有构造函数");
    }
//    public String toString() {
//        return "LayzzySingleTon2 同String";
//    }
    public static LayzzySingleton2 getInstance() {
        if (instance == null) {
            synchronized (LayzzySingleton2.class) {
                if (instance ==null) {
                    instance = new LayzzySingleton2();
                }
            }
        }
        return instance;
    }

}
